package cn.wolfcode.web.controller;

import cn.wolfcode.domain.Business;
import cn.wolfcode.qo.AllMsgQueryObject;
import cn.wolfcode.service.IBusinessReportService;
import cn.wolfcode.service.IBusinessService;
import cn.wolfcode.service.IConsumptionService;
import cn.wolfcode.util.AllMsgEnum;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/businessReport")
public class BusinessReportController {

    @Autowired
    private IBusinessService businessService;

    @Autowired
    private IConsumptionService consumptionService;

    @Autowired
    private IBusinessReportService businessReportService;


    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")AllMsgQueryObject qo){
        List<Business> businesses = businessService.listAll();
        model.addAttribute("businesses",businesses);

        PageInfo pageInfo = businessReportService.businessReport(qo);
        model.addAttribute("pageResult",pageInfo);
        AllMsgEnum[] values = AllMsgEnum.values();
        model.addAttribute("values",values);

            return "businessReport/list";
    }

    @RequestMapping("/pic")
    public String pic(Model model,@ModelAttribute("qo")AllMsgQueryObject qo){
        qo.setPageSize(0);
        PageInfo pageInfo = businessReportService.businessReport(qo);

        model.addAttribute("pageResult",pageInfo);
        return "businessReport/pic";
    }
}
